(0) Obligation:

The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(1, n^1).


The TRS R consists of the following rules:

sum(0) → 0
sum(s(x)) → +(sqr(s(x)), sum(x))
sqr(x) → *(x, x)
sum(s(x)) → +(*(s(x), s(x)), sum(x))

Rewrite Strategy: INNERMOST

(1) TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID) transformation)

Transformed TRS to weighted TRS

(2) Obligation:

The Runtime Complexity (innermost) of the given CpxWeightedTrs could be proven to be BOUNDS(1, n^1).


The TRS R consists of the following rules:

sum(0) → 0 [1]
sum(s(x)) → +(sqr(s(x)), sum(x)) [1]
sqr(x) → *(x, x) [1]
sum(s(x)) → +(*(s(x), s(x)), sum(x)) [1]

Rewrite Strategy: INNERMOST

(3) TypeInferenceProof (BOTH BOUNDS(ID, ID) transformation)

Infered types.

(4) Obligation:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

sum(0) → 0 [1]
sum(s(x)) → +(sqr(s(x)), sum(x)) [1]
sqr(x) → *(x, x) [1]
sum(s(x)) → +(*(s(x), s(x)), sum(x)) [1]

The TRS has the following type information:
sum :: 0:s:+ → 0:s:+
0 :: 0:s:+
s :: 0:s:+ → 0:s:+
+ :: * → 0:s:+ → 0:s:+
sqr :: 0:s:+ → *
* :: 0:s:+ → 0:s:+ → *

Rewrite Strategy: INNERMOST

(5) CompletionProof (UPPER BOUND(ID) transformation)

The transformation into a RNTS is sound, since:

(a) The obligation is a constructor system where every type has a constant constructor,

(b) The following defined symbols do not have to be completely defined, as they can never occur inside other defined symbols:


sum
sqr

(c) The following functions are completely defined:
none

Due to the following rules being added:
none

And the following fresh constants:

const

(6) Obligation:

Runtime Complexity Weighted TRS where critical functions are completely defined. The underlying TRS is:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

sum(0) → 0 [1]
sum(s(x)) → +(sqr(s(x)), sum(x)) [1]
sqr(x) → *(x, x) [1]
sum(s(x)) → +(*(s(x), s(x)), sum(x)) [1]

The TRS has the following type information:
sum :: 0:s:+ → 0:s:+
0 :: 0:s:+
s :: 0:s:+ → 0:s:+
+ :: * → 0:s:+ → 0:s:+
sqr :: 0:s:+ → *
* :: 0:s:+ → 0:s:+ → *
const :: *

Rewrite Strategy: INNERMOST

(7) NarrowingProof (BOTH BOUNDS(ID, ID) transformation)

Narrowed the inner basic terms of all right-hand sides by a single narrowing step.

(8) Obligation:

Runtime Complexity Weighted TRS where critical functions are completely defined. The underlying TRS is:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

sum(0) → 0 [1]
sum(s(x)) → +(sqr(s(x)), sum(x)) [1]
sqr(x) → *(x, x) [1]
sum(s(x)) → +(*(s(x), s(x)), sum(x)) [1]

The TRS has the following type information:
sum :: 0:s:+ → 0:s:+
0 :: 0:s:+
s :: 0:s:+ → 0:s:+
+ :: * → 0:s:+ → 0:s:+
sqr :: 0:s:+ → *
* :: 0:s:+ → 0:s:+ → *
const :: *

Rewrite Strategy: INNERMOST

(9) CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID) transformation)

Transformed the TRS into an over-approximating RNTS by (improved) Size Abstraction.
The constant constructors are abstracted as follows:

0 => 0
const => 0

(10) Obligation:

Complexity RNTS consisting of the following rules:

sqr(z) -{ 1 }→ 1 + x + x :|: x >= 0, z = x
sum(z) -{ 1 }→ 0 :|: z = 0
sum(z) -{ 1 }→ 1 + sqr(1 + x) + sum(x) :|: x >= 0, z = 1 + x
sum(z) -{ 1 }→ 1 + (1 + (1 + x) + (1 + x)) + sum(x) :|: x >= 0, z = 1 + x

(11) InliningProof (UPPER BOUND(ID) transformation)

Inlined the following terminating rules on right-hand sides where appropriate:

sqr(z) -{ 1 }→ 1 + x + x :|: x >= 0, z = x

(12) Obligation:

Complexity RNTS consisting of the following rules:

sqr(z) -{ 1 }→ 1 + x + x :|: x >= 0, z = x
sum(z) -{ 1 }→ 0 :|: z = 0
sum(z) -{ 2 }→ 1 + (1 + x' + x') + sum(x) :|: x >= 0, z = 1 + x, x' >= 0, 1 + x = x'
sum(z) -{ 1 }→ 1 + (1 + (1 + x) + (1 + x)) + sum(x) :|: x >= 0, z = 1 + x

(13) SimplificationProof (BOTH BOUNDS(ID, ID) transformation)

Simplified the RNTS by moving equalities from the constraints into the right-hand sides.

(14) Obligation:

Complexity RNTS consisting of the following rules:

sqr(z) -{ 1 }→ 1 + z + z :|: z >= 0
sum(z) -{ 1 }→ 0 :|: z = 0
sum(z) -{ 2 }→ 1 + (1 + x' + x') + sum(z - 1) :|: z - 1 >= 0, x' >= 0, 1 + (z - 1) = x'
sum(z) -{ 1 }→ 1 + (1 + (1 + (z - 1)) + (1 + (z - 1))) + sum(z - 1) :|: z - 1 >= 0

(15) CpxRntsAnalysisOrderProof (BOTH BOUNDS(ID, ID) transformation)

Found the following analysis order by SCC decomposition:

{ sum }
{ sqr }

(16) Obligation:

Complexity RNTS consisting of the following rules:

sqr(z) -{ 1 }→ 1 + z + z :|: z >= 0
sum(z) -{ 1 }→ 0 :|: z = 0
sum(z) -{ 2 }→ 1 + (1 + x' + x') + sum(z - 1) :|: z - 1 >= 0, x' >= 0, 1 + (z - 1) = x'
sum(z) -{ 1 }→ 1 + (1 + (1 + (z - 1)) + (1 + (z - 1))) + sum(z - 1) :|: z - 1 >= 0

Function symbols to be analyzed: {sum}, {sqr}

(17) IntTrsBoundProof (UPPER BOUND(ID) transformation)


Computed SIZE bound using CoFloCo for: sum
after applying outer abstraction to obtain an ITS,
resulting in: O(n2) with polynomial bound: 2·z + 2·z2

(18) Obligation:

Complexity RNTS consisting of the following rules:

sqr(z) -{ 1 }→ 1 + z + z :|: z >= 0
sum(z) -{ 1 }→ 0 :|: z = 0
sum(z) -{ 2 }→ 1 + (1 + x' + x') + sum(z - 1) :|: z - 1 >= 0, x' >= 0, 1 + (z - 1) = x'
sum(z) -{ 1 }→ 1 + (1 + (1 + (z - 1)) + (1 + (z - 1))) + sum(z - 1) :|: z - 1 >= 0

Function symbols to be analyzed: {sum}, {sqr}
Previous analysis results are:
sum: runtime: ?, size: O(n2) [2·z + 2·z2]

(19) IntTrsBoundProof (UPPER BOUND(ID) transformation)


Computed RUNTIME bound using CoFloCo for: sum
after applying outer abstraction to obtain an ITS,
resulting in: O(n1) with polynomial bound: 1 + 2·z

(20) Obligation:

Complexity RNTS consisting of the following rules:

sqr(z) -{ 1 }→ 1 + z + z :|: z >= 0
sum(z) -{ 1 }→ 0 :|: z = 0
sum(z) -{ 2 }→ 1 + (1 + x' + x') + sum(z - 1) :|: z - 1 >= 0, x' >= 0, 1 + (z - 1) = x'
sum(z) -{ 1 }→ 1 + (1 + (1 + (z - 1)) + (1 + (z - 1))) + sum(z - 1) :|: z - 1 >= 0

Function symbols to be analyzed: {sqr}
Previous analysis results are:
sum: runtime: O(n1) [1 + 2·z], size: O(n2) [2·z + 2·z2]

(21) ResultPropagationProof (UPPER BOUND(ID) transformation)

Applied inner abstraction using the recently inferred runtime/size bounds where possible.

(22) Obligation:

Complexity RNTS consisting of the following rules:

sqr(z) -{ 1 }→ 1 + z + z :|: z >= 0
sum(z) -{ 1 }→ 0 :|: z = 0
sum(z) -{ 1 + 2·z }→ 1 + (1 + x' + x') + s' :|: s' >= 0, s' <= 2 * ((z - 1) * (z - 1)) + 2 * (z - 1), z - 1 >= 0, x' >= 0, 1 + (z - 1) = x'
sum(z) -{ 2·z }→ 1 + (1 + (1 + (z - 1)) + (1 + (z - 1))) + s :|: s >= 0, s <= 2 * ((z - 1) * (z - 1)) + 2 * (z - 1), z - 1 >= 0

Function symbols to be analyzed: {sqr}
Previous analysis results are:
sum: runtime: O(n1) [1 + 2·z], size: O(n2) [2·z + 2·z2]

(23) IntTrsBoundProof (UPPER BOUND(ID) transformation)


Computed SIZE bound using CoFloCo for: sqr
after applying outer abstraction to obtain an ITS,
resulting in: O(n1) with polynomial bound: 1 + 2·z

(24) Obligation:

Complexity RNTS consisting of the following rules:

sqr(z) -{ 1 }→ 1 + z + z :|: z >= 0
sum(z) -{ 1 }→ 0 :|: z = 0
sum(z) -{ 1 + 2·z }→ 1 + (1 + x' + x') + s' :|: s' >= 0, s' <= 2 * ((z - 1) * (z - 1)) + 2 * (z - 1), z - 1 >= 0, x' >= 0, 1 + (z - 1) = x'
sum(z) -{ 2·z }→ 1 + (1 + (1 + (z - 1)) + (1 + (z - 1))) + s :|: s >= 0, s <= 2 * ((z - 1) * (z - 1)) + 2 * (z - 1), z - 1 >= 0

Function symbols to be analyzed: {sqr}
Previous analysis results are:
sum: runtime: O(n1) [1 + 2·z], size: O(n2) [2·z + 2·z2]
sqr: runtime: ?, size: O(n1) [1 + 2·z]

(25) IntTrsBoundProof (UPPER BOUND(ID) transformation)


Computed RUNTIME bound using CoFloCo for: sqr
after applying outer abstraction to obtain an ITS,
resulting in: O(1) with polynomial bound: 1

(26) Obligation:

Complexity RNTS consisting of the following rules:

sqr(z) -{ 1 }→ 1 + z + z :|: z >= 0
sum(z) -{ 1 }→ 0 :|: z = 0
sum(z) -{ 1 + 2·z }→ 1 + (1 + x' + x') + s' :|: s' >= 0, s' <= 2 * ((z - 1) * (z - 1)) + 2 * (z - 1), z - 1 >= 0, x' >= 0, 1 + (z - 1) = x'
sum(z) -{ 2·z }→ 1 + (1 + (1 + (z - 1)) + (1 + (z - 1))) + s :|: s >= 0, s <= 2 * ((z - 1) * (z - 1)) + 2 * (z - 1), z - 1 >= 0

Function symbols to be analyzed:
Previous analysis results are:
sum: runtime: O(n1) [1 + 2·z], size: O(n2) [2·z + 2·z2]
sqr: runtime: O(1) [1], size: O(n1) [1 + 2·z]

(27) FinalProof (EQUIVALENT transformation)

Computed overall runtime complexity

(28) BOUNDS(1, n^1)